package com.nf.health.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nf.health.app.R;

import java.util.List;
import java.util.Map;

/** 
 * @ClassName: ResultAdapter 
 * @Description: 自检  检查结果 页 适配器
 * @author Ian 
 * @date 2015-11-19 下午4:55:57 
 *  
 */
public class ResultAdapter extends BaseAdapter {

	private Context context;
	private List<Map<String,String>> doctors;


	public ResultAdapter(Context context, List<Map<String, String>> doctors) {
		super();
		this.context = context;
		this.doctors = doctors;
	}

	@Override
	public int getCount() {
		return doctors.size();
	}

	@Override
	public Object getItem(int position) {
		return doctors.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		holder = new ViewHolder();
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.result_item, null);
			holder = new ViewHolder();
			holder.name = (TextView) convertView.findViewById(R.id.result_name);
			holder.value = (TextView) convertView.findViewById(R.id.result_value);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.name.setText(doctors.get(position).get("eval_name"));
		holder.value.setText(doctors.get(position).get("eval_value"));

		return convertView;
	}
	static class ViewHolder {
		TextView name,value;
	}
}
